package cn.edu.zafu.bigdata.x.huangxihao202211080211;

import java.util.HashMap;

class StudentGradeManager {
    private HashMap<String, Integer> studentGrades;

    public StudentGradeManager() {
        studentGrades = new HashMap<>();
    }

    // 添加学生成绩
    public void addStudent(String name, int grade) {
        studentGrades.put(name, grade);
    }

    // 根据学生姓名获取成绩
    public int getGrade(String name) {
        return studentGrades.getOrDefault(name, -1);
    }

    // 删除学生成绩
    public void removeStudent(String name) {
        studentGrades.remove(name);
    }
}

public class StudentGradeManagerApp11 {
    public static void main(String[] args) {
        StudentGradeManager manager = new StudentGradeManager();

        // 添加学生成绩
        manager.addStudent("Alice", 90);
        manager.addStudent("Bob", 85);
        manager.addStudent("Charlie", 78);

        // 查询成绩
        System.out.println("Alice的成绩: " + manager.getGrade("Alice")); // 90
        System.out.println("Bob的成绩: " + manager.getGrade("Bob"));     // 85
        System.out.println("Charlie的成绩: " + manager.getGrade("Charlie")); // 78
        System.out.println("David的成绩: " + manager.getGrade("David"));   // -1

        // 删除学生成绩
        manager.removeStudent("Bob");
        System.out.println("删除Bob后，Bob的成绩: " + manager.getGrade("Bob")); // -1
    }
}

